import 'package:f_base_sy2/pages/detail_page.dart';
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('HomePage'),
        ),
        body: Center(
          child: Column(
            children: [
              Text('HomePage'),
              ElevatedButton(
                onPressed: () {
                  // 跳转到详情页  -- 写法1
                  Navigator.push(
                      context,
                      MaterialPageRoute(
                          builder: (context) => const DetailPage()));
                },
                child: Text('跳转到详情页 --写法1'),
              ),
              ElevatedButton(
                onPressed: () {
                  // 跳转到详情页  -- 写法2
                  Navigator.pushNamed(context, '/detail');
                },
                child: Text('跳转到详情页 -- 写法2'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
